<?php
namespace app\admin\model;
use think\Model;
use think\Db;

/**
 * 携号转网
 */
class ChangePhoneLocation extends Model
{
	public function getAll($request)
	{
		$where = [];

		if($request['phone']){

			$where[] = ['phone' , '=' , trim($request['phone'])];

		}

		return $this->where($where)->paginate($request['limit'])->each(function($item, $key){

			switch ($item->status) {
				case '1':
					$item->status = '开启';
					break;
				
				default:
					$item->status = '禁用';
					break;
			}

		})->toArray();
	}

	public function add($data)
	{
		$data['create_time'] = date('Y-m-d H:i:s');

		return $this->insert($data);
	}

	public function edit($id , $data)
	{
		return $this->where('id',$id)->update($data);
	}
	public function deletesome($id)
	{
		return $this->where('id','in',$id)->delete();
	}
}